<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" href="../static/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../static/css/font.css">
    <link rel="stylesheet" href="../static/lib/layui/css/layui.css">
    <link rel="stylesheet" href="../static/css/xadmin.css">
    <script src="../static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../static/js/xadmin.js"></script>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
  <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  <title>招聘大数据分析&nbsp;-&nbsp;注册</title>

  <style>
    body {
      background: url("../static/images/bizhi.png") no-repeat fixed;
      background-size: cover;
    }

    #big {
      height: 520px;
      width: 400px;
      position: absolute;
      top: 0%;
      bottom: 0;
      left: 64%;
      color: black;
      margin: auto;
      background-color: rgba(255, 255, 255, 0.2);
      border-radius: 15px;
    }

    #user_id,
    #user_name,
    #password,
    #e_mail,
    #education,
    #work_experience,
    #current_work,
    #current_pay,
    #foretell_work01,
    #foretell_work02,
    #foretell_work03 {
      width: 300px;
      height: 45px;
    }

    .demo {
      opacity: 0;
      position: absolute;
      margin-left: 54px;
      margin-top: 44px;
    }

    .demo>input {
      margin-bottom: 16px
    }

    #demo {
      opacity: 1;
      z-index: 100;
    }
    #kz_one{
			font-size: 16px;
			padding: 15px;
			color: white;
            text-decoration: none ;
		}


  </style>
</head>
<body>
<!-- layui-->
 <div class="layui-form" >
  <div class="layui-form-item">

<div id="big">
    <a href="/login" class="glyphicon glyphicon-triangle-left" id="kz_one">已有账号，返回登录</a>

  <div style="position: relative;">
    <div id="demo" class="demo">
      <input type="text"  class="form-control" id="user_id" placeholder="账号">
      <input type="text" class="form-control" id="user_name" placeholder="用户名">
      <input type="password" class="form-control" id="password" placeholder="密码">
      <input type="text" class="form-control" id="e_mail" placeholder="邮箱">


              <select   class="form-control" id="education" lay-search   >
            <option  value="不限"  selected >请输入学历</option>
            {% for i  in  education %}
            <option  value={{ i[0] }}   >{{ i[0] }} </option>
            {% endfor  %}
            </select>

      <br>
      <button type="button" class="bb btn btn-primary" id="signIn1">下一步</button>
    </div>

    <div class="demo">
               <select   class="form-control" id="work_experience" lay-search   >
            <option  value="0"  selected >工作经验</option>
            {% for i  in  range(0,70) %}
            <option  value={{ i }}   >{{ i }} </option>
            {% endfor  %}
            </select>
          <br>






          <select   class="form-control" id="current_work" lay-search   >
            <option  value="普工"  selected >当前工作岗位</option>
            {% for i  in  position %}
            <option  value={{ i[0] }}   >{{ i[0] }} </option>
            {% endfor  %}
            </select>
          <br>


      <input type="text" class="form-control" id="current_pay" placeholder="当前薪资">




         <select   class="form-control" id="foretell_work01" lay-search   >
            <option  value="普工"  selected >预测工作一</option>
            {% for i  in  position %}
            <option  value={{ i[0] }}   >{{ i[0] }} </option>
            {% endfor  %}
            </select>
          <br>


               <select   class="form-control" id="foretell_work02" lay-search   >
            <option  value="普工"  selected >预测工作一</option>
            {% for i  in  position %}
            <option  value={{ i[0] }}   >{{ i[0] }} </option>
            {% endfor  %}
            </select>
          <br>



        <select   class="form-control" id="foretell_work03" lay-search   >
            <option  value="普工"  selected >预测工作一</option>
            {% for i  in  position %}
            <option  value={{ i[0] }}   >{{ i[0] }} </option>
            {% endfor  %}
            </select>
          <br>


      <button type="button" class="aa btn btn-primary" id="signIn2">上一步</button>
      <button type="button" class="btn btn-primary" id="signIn">注册</button>
    </div>
  </div>
</div>


  </div>
 </div>


       <div style="position:absolute;bottom:-30px;width: 100%">
          <p style="opacity: 0.8;text-align:center;color:white;">&copy; 2021 全国招聘大数据分析系统</p>
        </div>


</body>

<script>
  //Demo
  layui.use('form', function () {
    var form = layui.form;

    //监听提交
    form.on('submit(formDemo)', function (data) {
      layer.msg(JSON.stringify(data.field));
      return false;
    });
  });
</script>
<script>
  // $("")
  $(function () {


    $(".aa").click(function(){
      demo1(0)
    })

    var demo = $(".demo");
    console.log(demo)
    var bb = $(".bb")
    for (let i = 0; i < bb.length; i++) {
      console.log(0)
      bb[i].addEventListener("click", function () {
        demo1(i + 1);
      })
    }

    function demo1(id) {
      for (let i = 0; i < demo.length; i++) {
        console.log(i)
        if (i == id) {
          demo[i].id = "demo";
        } else {
          demo[i].id = '';
        }
      }
    }
  })
  // 嘤嘤嘤
  $("#signIn").click(
    function () {
            var  user_id = $('#user_id').val();
            var  user_name = $('#user_name').val();
            var  e_mail = $('#e_mail').val();
            var  work_experience = $('#work_experience').val();
            var  current_pay =  $('#current_pay').val();
            var  password = $('#password').val();
            var  education =   $('#education').val();
            var  current_work = $('#current_work').val();
            var  foretell_work01 =  $('#foretell_work01').val();
            var  foretell_work02 =  $('#foretell_work02').val();
            var   foretell_work03 =  $('#foretell_work03').val();

		    if ( user_name !="" && ! user_name.match("(.*?) (.*?)")  &&
            e_mail !="" && ! e_mail.match("(.*?) (.*?)")  &&
                    e_mail.match("[a-zA-Z0-9]+@[a-zA-Z0-9]+(.*?)")  &&
            work_experience !="" && ! work_experience.match("(.*?) (.*?)") &&
            user_id !="" && ! user_id.match("(.*?) (.*?)") &&
            user_id.match("[0-9a-zA-Z]+") &&
            user_id.length>=6 &&
            password.length>=6 &&
             current_pay !=""  && ! current_pay.match("(.*?) (.*?)") && current_pay.match("[0-9]+") &&
            password !="" && ! password.match("(.*?) (.*?)") &&
            education !="" && ! education.match("(.*?) (.*?)") &&
            current_work !="" && ! current_work.match("(.*?) (.*?)") &&
            foretell_work01 !="" && ! foretell_work01.match("(.*?) (.*?)") &&
            foretell_work02 !="" && ! foretell_work02.match("(.*?) (.*?)") &&
            foretell_work03 !="" && ! foretell_work03.match("(.*?) (.*?)")) {
              $.ajax({
                //请求方式
                type: "POST",
                //请求的媒体类型
                contentType: "application/json;charset=UTF-8",
                //请求地址
                url: "/signIn",
                //数据，json字符串
                data: JSON.stringify({
                  'user_id': $('#user_id').val(),
                  'user_name': $('#user_name').val(),
                  'password': $('#password').val(),
                  'e_mail': $('#e_mail').val(),
                  'education': $('#education').val(),
                  'work_experience': $('#work_experience').val(),
                  'current_work': $('#current_work').val(),
                  'current_pay': $('#current_pay').val(),
                  'foretell_work01': $('#foretell_work01').val(),
                  'foretell_work02': $('#foretell_work02').val(),
                  'foretell_work03': $('#foretell_work03').val()
                }),
                //请求成功
                success: function (result) {
                  if (result == "success") {
                    // $(location).attr('href', '/login');
                    $.ajax({
                      //请求方式
                      type: "POST",
                      //请求的媒体类型
                      contentType: "application/json;charset=UTF-8",
                      //请求地址
                      url: "/login",
                      //数据，json字符串
                      data: JSON.stringify({
                        'user_id': $('#user_id').val(),
                        'password': $('#password').val(),
                      }),
                      //请求成功
                      success: function (result) {
                        if (result == "success") {
                          $(location).attr('href', '/');
                        }
                        // else if(result == "fail"){
                        //     $(location).attr('href', '/management');
                        // }
                        if (result == "user_exist") {
                          layer.open({
                          title: '提示',
                          content: '用户ID已存在！'
                            });
                          // alert("用户ID已存在")
                        }
                      },
                      //请求失败，包含具体的错误信息
                      error: function (e) {
                        console.log(e.status);
                        console.log(e.responseText);
                      }
                    });


                  }

                  if (result == "user_exist") {
                    layer.open({
                          title: '提示',
                          content: '用户ID已存在！'
                            });
                    // alert("用户ID已存在")
                  }
                },
                //请求失败，包含具体的错误信息
                error: function (e) {
                  console.log(e.status);
                  console.log(e.responseText);
                }
              });
            }else if( ! user_id.match("[0-9a-zA-Z]+")){
		        layer.open({
                title: '提示',
                content: '账号只能为数字或英文字符！'
            });
            }else if( !  e_mail.match("[a-zA-Z0-9]+@[a-zA-Z0-9]+(.*?)")){
		        layer.open({
                title: '提示',
                content: '邮箱输入格式错误！'
            });
            }else if( !  current_pay.match("[0-9]+")){
		        layer.open({
                title: '提示',
                content: '当前薪资输入格式错误！只能为数字'
            });
            }else if(   user_id.length<6){
		        layer.open({
                title: '提示',
                content: 'ID小于6位'
            });
            }else if( password.length<6){
		        layer.open({
                title: '提示',
                content: '密码小于6位'
            });
            }else{
		        layer.open({
                title: '提示',
                content: '内容含空格或为空！'
            });
            }
    }
  )
</script>

</html>